home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Burning & Media / GB-PVR 1.2.13 / GBPVR10213.msi / Cabs.w1.cab / Header.ascx.cs402 < prev    next >
Text File  |  2008-01-01  |  8KB  |  189 lines

  1. using System;
  2. using System.IO;
  3. using System.Web;
  4. using System.Web.UI;
  5. using System.Xml;
  6.  
  7. namespace gbweb
  8. {
  9.     /// <summary>
  10.     ///        Summary description for Header.
  11.     /// </summary>
  12.     public partial class Header : UserControl
  13.     {
  14.  
  15.         public string ActiveTab;
  16.         private Settings guideParams;
  17.  
  18.         protected void Page_Load(object sender, EventArgs e)
  19.         {
  20.             headerList.Items.Clear();
  21.             guideParams = Global.Settings;
  22.             logo.Src = logo.Src.Replace("images", Convert.ToString(Session["theme"]));
  23.             logo.Attributes.Add("title", Global.Settings.GetVersionToolTip());
  24.             header.Attributes.Add("class", ActiveTab);
  25.  
  26.             headerList.Items.Add("<a href=\"Guide.aspx\"><span>TV Guide</span></a>");
  27.             headerList.Items.Add("<a href=\"Manage.aspx\"><span>Manage Recordings</span></a>");
  28.             headerList.Items.Add("<a href=\"Search.aspx\"><span>Episode Search</span></a>");
  29.             headerList.Items.Add("<a href=\"Library.aspx?path=Video\"><span>Video Library</span></a>");
  30.             headerList.Items.Add("<a href=\"Library.aspx?path=Music\"><span>Music Library</span></a>");
  31.             headerList.Items.Add("<a href=\"PhotoViewer.aspx\"><span>Photo Library</span></a>");
  32.             headerList.Items.Add("<a href=\"Logout.aspx\"><span>Logout</span></a>");
  33.             headerList.Items.Add("<a href=\"Admin.aspx\"><span>Config</span></a>");
  34.             headerList.Items.Add("<a href=\"Info.aspx\"><span>Statistics</span></a>");
  35.  
  36.             headerList.Items[0].Attributes.Add("id", "nav-guide");
  37.             headerList.Items[1].Attributes.Add("id", "nav-manage");
  38.             headerList.Items[2].Attributes.Add("id", "nav-search");
  39.             headerList.Items[3].Attributes.Add("id", "nav-Videolibrary");
  40.             headerList.Items[4].Attributes.Add("id", "nav-Musiclibrary");
  41.             headerList.Items[5].Attributes.Add("id", "nav-Photolibrary");
  42.             headerList.Items[6].Attributes.Add("id", "nav-logout");
  43.             headerList.Items[7].Attributes.Add("id", "nav-admin");
  44.             headerList.Items[8].Attributes.Add("id", "nav-info");
  45.  
  46.             headerList.Items[6].Attributes.Add("class", "farright");
  47.             headerList.Items[7].Attributes.Add("class", "farright");
  48.             headerList.Items[8].Attributes.Add("class", "farright");
  49.  
  50.             if (!guideParams.showStats)
  51.             {
  52.                 headerList.Items.RemoveAt(8);
  53.             }
  54.             //Guest users do not have access to the Admin console
  55.             if (!Convert.ToBoolean((string) Session["NotGuestUser"]))
  56.             {
  57.                 headerList.Items.RemoveAt(7);
  58.             }
  59.             if (!guideParams.showPhotoLib)
  60.             {
  61.                 headerList.Items.RemoveAt(5);
  62.             }
  63.  
  64.             if (!guideParams.showMusicLib)
  65.             {
  66.                 headerList.Items.RemoveAt(4);
  67.             }
  68.  
  69.             if (!guideParams.showVideoLib)
  70.             {
  71.                 headerList.Items.RemoveAt(3);
  72.             }
  73.             //Guest users do not have access to episode search
  74.             if (!guideParams.showSearch || (!Convert.ToBoolean((string)Session["NotGuestUser"])))
  75.             {
  76.                 headerList.Items.RemoveAt(2);
  77.             }
  78.  
  79.             if (!guideParams.showManage)
  80.             {
  81.                 headerList.Items.RemoveAt(1);
  82.             }
  83.  
  84.             if (!guideParams.showTVGuide)
  85.             {
  86.                 headerList.Items.RemoveAt(0);
  87.             }
  88.  
  89.             getTheme();
  90.  
  91.             //The below code is what is necessary to use the plugins directory in support of EWA plugins.
  92.             //The tabs are created from this code behind by reading the subdirectories under the plugins dirctory.
  93.             //This provides the ability for users to add new tabs of functionality or overide current functionality
  94.             //such as replacing the standard guide with one of thier own.
  95.  
  96.             //XmlDocument configPlugins;
  97.             //string id = "";
  98.             //string href = "";
  99.             //string displayname = "";
  100.             //string[] plugins = Directory.GetDirectories(Server.MapPath(Request.ApplicationPath + "/plugins/"));
  101.             //headerList.InnerHtml = "";
  102.             //Array.Sort(plugins);
  103.             //foreach (string plugin in plugins)
  104.             //{
  105.             //    if (File.Exists(Path.Combine(plugin, "plugin_config.xml")))
  106.             //    {
  107.             //        configPlugins = new XmlDocument();
  108.             //        configPlugins.Load(Path.Combine(plugin, "plugin_config.xml"));
  109.             //        // Retrieve all categories from the xml.
  110.             //        XmlNodeList categories = configPlugins.SelectNodes("plugin_config");
  111.             //        foreach (XmlNode pluginNode in categories)
  112.             //        {
  113.             //            id = pluginNode.SelectSingleNode("//plugin_id").InnerText;
  114.             //            href = pluginNode.SelectSingleNode("//plugin_href").InnerText;
  115.             //            displayname = pluginNode.SelectSingleNode("//plugin_display_name").InnerText;
  116.             //            headerList.InnerHtml += "<li id=\"" + id + "\"><a href=\"" + href + "\"><span>" + displayname + "</span></a></li>";
  117.             //        }
  118.             //    }
  119.             //}
  120.             //headerList.InnerHtml += "<li id=\"nav-logout\" class=\"farright\"><a href=\"Logout.aspx\"><span>Logout</span></a></li>";
  121.             //headerList.InnerHtml += "<li id=\"nav-admin\" class=\"farright\"><a href=\"Admin.aspx\"><span>Config</span></a></li>";
  122.             //headerList.InnerHtml += "<li id=\"nav-info\" class=\"farright\"><a href=\"Info.aspx\"><span>Statistics</span></a></li>";
  123.         }
  124.  
  125.         protected void Page_PreRender(object sender, System.EventArgs e)
  126.         {
  127.  
  128.         }
  129.  
  130.         private void getTheme()
  131.         {
  132.             //Check to see if the theme has been set in session and that the set theme is using the table view
  133.             string theme = Convert.ToString(Session["theme"]);
  134.  
  135.             if (theme != null && theme != "" && theme.Substring(0, 7) == "themes/")
  136.             {
  137.                 return;
  138.             }
  139.             else
  140.             {
  141.                 //Since the session theme variable was not set or is using the css view we need to read the value from the cookie
  142.                 HttpCookie cookie = Request.Cookies["theme"];
  143.                 if (cookie != null && cookie.Value.Length > 0)
  144.                 {
  145.                     theme = cookie.Value;
  146.                 }
  147.                 else
  148.                 {
  149.                     theme = "Default";
  150.                 }
  151.  
  152.                 //Verify that that the theme in the cookie is available in the table based selections.  If it is not found set the theme to Default.
  153.                 if (File.Exists(HttpContext.Current.Server.MapPath("~/themes/") + theme + "/styles.css"))
  154.                 {
  155.                     Session["theme"] = "themes/" + theme;
  156.                 }
  157.                 else
  158.                 {
  159.                     Session["theme"] = "themes/Default"; 
  160.                 }
  161.  
  162.             
  163.  
  164.                 return;
  165.             }
  166.         }
  167.  
  168.         #region Web Form Designer generated code
  169.         override protected void OnInit(EventArgs e)
  170.         {
  171.             //
  172.             // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  173.             //
  174.             InitializeComponent();
  175.             base.OnInit(e);
  176.         }
  177.         
  178.         /// <summary>
  179.         ///        Required method for Designer support - do not modify
  180.         ///        the contents of this method with the code editor.
  181.         /// </summary>
  182.         private void InitializeComponent()
  183.         {
  184.  
  185.         }
  186.         #endregion
  187.     }
  188. }
  189.